var memberData = {
  "1": {
    job: "创始人",
    name: "胡歌",
    desc: "胡歌胡歌胡歌胡歌胡歌胡歌",
  },
  "2": {
    job: "技术总监",
    name: "霍建华",
    desc: "霍建华霍建华霍建华霍建华",
  },
  "3": {
    job: "HR主管",
    name: "赵丽颖",
    desc: "赵丽颖赵丽颖赵丽颖赵丽颖",
  },
  "4": {
    job: "保安队长",
    name: "冯绍峰",
    desc: "冯绍峰冯绍峰冯绍峰冯绍峰冯绍峰",
  },
  "5": {
    job: "看门大爷",
    name: "陈柏霖",
    desc: "陈柏霖陈柏霖陈柏霖陈柏霖陈柏霖",
  },
  "6": {
    job: "行政主管",
    name: "王珞丹",
    desc: "王珞丹王珞丹王珞丹王珞丹王珞丹",
    imgUrl: "./static/img/memberImg.png",
  },
};

$(document).ready(function () {
  $(".otherMember").on("click", function () {
    var objThis = $(this);
    var id = objThis.data("id");
    $(".mainMemberImg img").attr("src", memberData[id].imgUrl);
    $(".jobPosition").text(memberData[id].job);
    $(".memberName").text(memberData[id].name);
    $(".memberText").text(memberData[id].desc);
  });
  $(".memberImgForPhone").on("click", function () {
    var objThis = $(this);
    var id = objThis.data("id");
    $(".mainMemberImg img").attr("src", memberData[id].imgUrl);
    objThis.attr("src", memberData[id].imgUrl);
    $(".jobPosition").text(memberData[id].job);
    $(".memberName").text(memberData[id].name);
    $(".memberText").text(memberData[id].desc);
  });
  $(".owl-carousel").owlCarousel({
    margin: 20,
    dots: true,
    responsive: {
      0: {
        items: 1,
      },
      768: {
        items: 2,
      },
      992: {
        items: 3,
      },
    },
  });
  $("#homeNav,#totop").on("click", function (e) {
    scrollTo("html", 300);
  });

  $("#productNav").on("click", function (e) {
    scrollTo("#product", 300);
  });
  $("#goodsNav").on("click", function () {
    scrollTo("#goods", 300);
  });
  $("#newsNav").on("click", function (e) {
    scrollTo("#news", 300);
  });
  $("#devStatusNav").on("click", function (e) {
    scrollTo("#devStatusTitle", 300);
  });
  $("#aboutusNav").on("click", function (e) {
    scrollTo("#aboutus", 300);
  });
  $(".owl-dots").on("click", ".owl-dot", function () {
    var objThis = $(this);
    objThis.siblings(".owl-dot").removeClass("active");
    objThis.addClass("active");
  });
  $(window).scroll(function () {
    var topp = $(document).scrollTop();
    $("#qqConsult").css("top", topp + 200);
    $("#totop").css("top", topp + $(window).height() * 0.8)
    if (topp >= 0) {
      $('.indexNav .navbar-nav .nav-item').removeClass('active')
      $("#homeNav").parent('.nav-item').addClass('active')
    }
    if (topp >= $('#product').offset().top - 100) {
      $('.indexNav .navbar-nav .nav-item').removeClass('active')
      $("#productNav").parent('.nav-item').addClass('active')
    }
    if (topp >= $('#goods').offset().top - 110) {
      $('.indexNav .navbar-nav .nav-item').removeClass('active')
      $("#goodsNav").parent('.nav-item').addClass('active')
    }
    if (topp >= $('#devStatusTitle').offset().top - 110) {
      $('.indexNav .navbar-nav .nav-item').removeClass('active')
      $("#devStatusNav").parent('.nav-item').addClass('active')
    }
    if (topp >= $('#news').offset().top - 110) {
      $('.indexNav .navbar-nav .nav-item').removeClass('active')
      $("#newsNav").parent('.nav-item').addClass('active')
    }
    if (topp >= $('#aboutus').offset().top - 110) {
      $('.indexNav .navbar-nav .nav-item').removeClass('active')
      $("#aboutusNav").parent('.nav-item').addClass('active')
    }
  });
});

function scrollTo(ele, speed) {
  if (!speed) speed = 300;
  if (!ele) {
    $("html,body").animate({ scrollTop: 0 }, speed);
  } else {
    if (ele.length > 0)
      $("html,body").animate({ scrollTop: $(ele).offset().top - 100 }, speed);
  }
  return false;
}
